<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
<div class="login-box">
    <div>
        <label>用户名:</label><input id="username"/>
    </div>
    <div>
        <label>密码:</label><input id="password"/>
    </div>
   <div>
       <button id="btnLogin">
           登录
       </button>

   </div>

</div>
</body>
<script>

    var btnLogin = document.getElementById('btnLogin');
    btnLogin.onclick= function () {

        var user = {
            username:document.getElementById('username').value,
            password:document.getElementById('password').value,
            status:'login'
        }

        /***
         *  json序列化： JSON.stringify()
         * */

        alert(JSON.stringify(user));
        localStorage.setItem("user",JSON.stringify(user));

        window.location.href = "index.html";
    }

</script>
</html>